<x-app-layout>
    <x-slot name="header">
        <h2 class="font-semibold text-xl text-gray-800 dark:text-gray-200 leading-tight">
            {{ __('Dashboard') }}
        </h2>
    </x-slot>

    <div class="py-12">
        <div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
            <div class="bg-white dark:bg-gray-800 overflow-hidden shadow-sm sm:rounded-lg">
                <div class="p-6 text-gray-900 dark:text-gray-100">
                    {{ __("You're logged in!") }}
                </div>
            </div>
        </div>
    </div>

    <script type="module">
        window.Echo.private('App.Models.User.{{auth()->id()}}')
            .listen('.msg', (e) => {
                console.log(e);
            });

        window.Echo.channel('system')
            .listen('.msg', (e) => {
                console.log(e);
            });

        Echo.join(`chat.123`)
            .here((users) => {
                console.log("users");
                console.log(users);
            })
            .joining((user) => {
                console.log(user.name);
            })
            .leaving((user) => {
                console.log(user.name);
            })
            .error((error) => {
                console.error(error);
            });

    </script>

</x-app-layout>
